const xlsx = require("node-xlsx");
const fs = require("fs");

// 规定传入格式
let sample = [
  {
    name: "sheet_name",
    data: [
      [
        "PSY_Supervisor",
        "PSY_Supervisor_Login",
        37,
        "中",
        "退出账号登录",
        "登录且处于主页页面",
        "1.将光标移至账号头像处2.选择“退出登录”3.确认操作",
        "退出成功：处于登录页面，且无法直接访问主页页面",
        "通过",
      ],
      [
        "PSY_Supervisor",
        "PSY_Supervisor_Login",
        38,
        "中",
        "退出账号登录",
        "登录且处于主页页面",
        "1.将光标移至账号头像处2.选择“退出登录”3.确认操作",
        "退出成功：处于登录页面，且无法直接访问主页页面",
        "通过",
      ],
    ],
  },
];
module.exports = {
  "generateXlsx": (data, fileName) => {
    const buffer = xlsx.build(data);
    fs.writeFile(`${fileName}.xlsx`, buffer, function (err) {
      if (err) {
        console.log(err, "保存excel出错");
      } else {
        console.log("写入excel成功!");
      }
    });
  },
};
